#include "Dof.h"
#include <string.h>
#include <stdio.h>


double inf = 1e9;

int Dof::mDofCount=DOF_MAGIC_NO;

void Dof::init(double _v, char * _name, double _min, double Max){
	mName= new char[128];
	strcpy(mName, _name);
	//printf("name: %s\n", mName);
	mVelocity = 0.0;
	mVal=_v;
	mInitVal = _v;
	mLastVal = _v;
	mMin=_min;
	mMax=Max;
	mID=Dof::mDofCount++;
	mModelID=-1;
	mDerivFlag=false;
	mVariable=false;
	mTrans=NULL;
	mJoint=NULL;	// remains null if const dof
}

Dof::Dof(){
	init(0, "dof", -inf , inf );
}

Dof::Dof(double _v){
	init(_v, "dof", -inf , inf );
}

Dof::Dof(double _v, char * _name){
	init(_v, _name, -inf , inf );
}

Dof::Dof(double _v, double _min, double Max){
	init(_v, "dof", _min, Max);
}

Dof::Dof(double _v, char * _name, double _min, double Max){
	init(_v, _name, _min, Max);
}

void Dof::switchBetweenLastAndCurrentValue()
{
	double tmp = mVal;
	mVal = mLastVal;
	mLastVal = tmp;
}
